package BankingTaskManagement;

import java.util.ArrayList;
import java.util.HashMap;

public class BankingTaskManager {
    protected HashMap<String, BankAccount> accounts;
    private TaskManager taskManager;

    public BankingTaskManager() {
        accounts = new HashMap<>();
        taskManager = new TaskManager();
    }

    public void createAccount(String accountNumber, double balance, double annualInterestRate) {
        if (!accounts.containsKey(accountNumber)) {
            accounts.put(accountNumber, new BankAccount(balance, annualInterestRate));
            System.out.println("Account created successfully.");
        } else {
            System.out.println("Account already exists.");
        }
    }

    public boolean deposit(String accountNumber, double amount) {
        if (accounts.containsKey(accountNumber)) {
            accounts.get(accountNumber).deposit(amount);
            taskManager.addTask("Deposit RMB " + amount + " to Account " + accountNumber);
            return true;
        } else {
            System.out.println("Account not found.");
            return false;
        }
    }

    public boolean withdraw(String accountNumber, double amount) {
        if (accounts.containsKey(accountNumber)) {
            boolean withdrawSuccess = accounts.get(accountNumber).withdraw(amount);
            if (withdrawSuccess) {
                taskManager.addTask("Withdraw RMB " + amount + " from Account " + accountNumber);
                return true;
            } else {
                return false;
            }
        } else {
            System.out.println("Account not found.");
            return false;
        }
    }

    public void viewAccountDetails(String accountNumber) {
        if (accounts.containsKey(accountNumber)) {
            accounts.get(accountNumber).displayAccountDetails();
        } else {
            System.out.println("Account not found.");
        }
    }

    public void viewTasks() {
        taskManager.displayTasks();
    }

    public void addTask(String task) {
        taskManager.addTask(task);
    }

    public void removeTask(String priority, int index) {
        taskManager.removeTask(priority, index);
    }

    public void changePriority(String priority, int index) {
        taskManager.changePriority(priority, index);
    }

    public void promoteTask(int index) {
        taskManager.promoteTask(index);
    }

    public ArrayList<String> getHighPriorityTasks() {
        return taskManager.getHighPriorityTasks();
    }

    public ArrayList<String> getLowPriorityTasks() {
        return taskManager.getLowPriorityTasks();
    }
}